﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DiaryPlanner
{
    interface ChangeCalendar
    {
        void setDateLabel();
    }

    class ChangeMonth : ChangeCalendar
    {
        public Planner planner;

        public ChangeMonth(Planner planner)
        {
            this.planner = planner;
            setDateLabel();
        }

        public void setDateLabel()
        {
            planner.plannerMonth.myDT = planner.monthCalendar1.SelectionStart;

            planner.plannerMonth.viewAll();
            planner.plannerDay.viewAllDB();

            planner.setDateLabel();
            
            planner.plannerMonth.month_Click(planner.plannerMonth.getMonthList
                (planner.monthCalendar1.SelectionStart.Day + planner.plannerMonth.getFirstWeek()));
        }
    }

    class ChangeWeek : ChangeCalendar
    {
        Planner planner;
        PlannerWeek plannerWeek;

        public ChangeWeek(Planner planner, PlannerWeek plannerWeek)
        {
            this.planner = planner;
            this.plannerWeek = plannerWeek;

            setDateLabel();
        }

        public void setDateLabel()
        {
            DateTime temp = planner.monthCalendar1.SelectionStart;

            planner.plannerMonth.myDT = planner.monthCalendar1.SelectionStart;
            planner.plannerMonth.viewAll();

            switch (planner.monthCalendar1.SelectionStart.DayOfWeek)
            {
                case DayOfWeek.Sunday:
                    break;
                case DayOfWeek.Monday:
                    temp = temp.AddDays(-1);
                    break;
                case DayOfWeek.Tuesday:
                    temp = temp.AddDays(-2);
                    break;
                case DayOfWeek.Wednesday:
                    temp = temp.AddDays(-3);
                    break;
                case DayOfWeek.Thursday:
                    temp = temp.AddDays(-4);
                    break;
                case DayOfWeek.Friday:
                    temp = temp.AddDays(-5);
                    break;
                case DayOfWeek.Saturday:
                    temp = temp.AddDays(-6);
                    break; ;
            }

            planner.setDateLabel();

            temp = temp.AddDays(6);
            
            planner.plannerMonth.month_Click(planner.plannerMonth.getMonthList
                (planner.monthCalendar1.SelectionStart.Day + planner.plannerMonth.getFirstWeek()));

            planner.setDateLabel(temp);

            plannerWeek.setWeekLabel();
            plannerWeek.viewAllDB();
        }
    }
}
